@extends('layouts.admin')
@section('content')
    <script type="text/javascript" charset="utf-8" src="{{asset('resources/org/ueditor/ueditor.config.js')}}"></script>
    <script type="text/javascript" charset="utf-8" src="{{asset('resources/org/ueditor/ueditor.all.min.js')}}"> </script>
    <!--建议手动加在语言，避免在ie下有时因为加载语言失败导致编辑器加载失败-->
    <!--这里加载的语言文件会覆盖你在配置项目里添加的语言类型，比如你在配置项目里配置的是英文，这里加载的中文，那最后就是中文-->
    <script type="text/javascript" charset="utf-8" src="{{asset('resources/org/ueditor/lang/zh-cn/zh-cn.js')}}"></script>

    <!--面包屑导航 开始-->
    <div class="crumb_warp">
        <!--<i class="fa fa-bell"></i> 欢迎使用登陆网站后台，建站的首选工具。-->
        <i class="fa fa-home"></i> <a href="{{url('admin/info')}}">首页</a> &raquo; <a href="{{url('admin/cate')}}">文章管理</a> &raquo; 添加文章
    </div>
    <!--面包屑导航 结束-->
    
    <div class="result_wrap">
        <div class="result_title">
            <h3>添加文章</h3>
            @if(count($errors))
                <div class="mark">
                    @if(is_object($errors))
                        @foreach($errors->all() as $error)
                            <p style="font-size:14px;font-weight:bold">{{$error}}</p>
                        @endforeach
                    @else
                        <p style="font-size:14px;font-weight:bold">{{$errors}}</p>
                    @endif
                </div>
            @endif
        </div>
        <form method="post" action="{{url('admin/article')}}">
            {{csrf_field()}}
            <table class="add_tab">
                <tbody>
                    <tr>
                        <th width="120">所属分类：</th>
                        <td>
                            <select name="cate_id">
                                @foreach($category as $cate)<option value="{{$cate->cate_id}}">{{$cate->_cate_name}}</option>
                                @endforeach
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <th><i class="require">*</i>文章标题：</th>
                        <td>
                            <input type="text" class="lg" name="art_title"> <br>
                            <span><i class="fa fa-exclamation-circle yellow"></i>文章标题必须填写</span>
                        </td>
                    </tr>
                    <tr>
                        <th>编辑人：</th>
                        <td>
                            <input type="text" size="30px" name="art_editor">
                        </td>
                    </tr>
                    <tr>
                        <th>缩略图：</th>
                        <script src="{{asset('/resources/org/uploadify/jquery.uploadify.min.js')}}" type="text/javascript"></script>
                        <link rel="stylesheet" type="text/css" href="{{asset('/resources/org/uploadify/uploadify.css')}}">
                        <td>
                            <input type="text" size="30px" name="art_thumb">
                            <input type="file" size="40px" name="file_upload" id="file_upload" >
                            <style>
                                .uploadify{display:inline-block;}
                                .uploadify-button{border:none; border-radius:5px; margin-top:8px;}
                                table.add_tab tr td span.uploadify-button-text{color: #FFF; margin:0;}
                            </style>
                        <script type="text/javascript">
                            $(function() {
                                $('#file_upload').uploadify({
                                    'buttonImage': '',
                                    'multi' : false,
                                    'fileTypeExts' : '*.jpg;*.png;*.gif',
                                    'buttonText' : '请选择图片文件',
                                    'formData'     : {
                                        '_token'     : "{{csrf_token()}}"
                                    },
                                    'swf'      : '{{asset("resources/org/uploadify/uploadify.swf")}}',
                                    'uploader' : '{{url("admin/article/upload")}}',
                                    'onUploadSuccess':function (file,data,response){
                                      var data = JSON.parse(data);
                                        if(data.status == 0){
                                            //回显图片
                                            var base = "{{url('')}}";
                                           $('#showImg').attr('src',base+ '/'+'uploads/'+data.url);
                                            $("input[name='art_thumb']").val(data.url);
                                            //将上传后的地址设置到表单
                                        }else{
                                            // 上传失败
                                        }
                                    }
                                });
                            });
                        </script>
                            <img src="" id="showImg" style="max-width:220px;max-height:90px">
                        </td>
                    </tr>

                    <tr>
                        <th>文章排序：</th>
                        <td>
                            <input type="text" class="sm" name="art_order" value="0">
                        </td>
                    </tr>
                    <tr>
                        <th>关键词：</th>
                        <td>
                            <input type="text" class="lg" name="art_tag">
                        </td>
                    </tr>
                    <tr>
                        <th>描述：</th>
                        <td>
                            <textarea name="art_description"></textarea>
                        </td>
                    </tr>
                    <tr>
                        <th>内容：</th>
                        <td>
                            <style>
                                .edui-default{line-height: 28px;}
                                div.edui-combox-body,div.edui-button-body,div.edui-splitbutton-body
                                {overflow: hidden; height:20px;}
                                div.edui-box{overflow: hidden; height:22px;}
                            </style>
                            <script> var ue = UE.getEditor('editor');</script>
                            <script name="art_content" id="editor" type="text/plain" style="width:850px;height:400px;"></script>
                        </td>
                    </tr>

                    <tr>
                        <th></th>
                        <td>
                            <input type="submit" value="提交">
                            <input type="button" class="back" onclick="history.go(-1)" value="返回">
                        </td>
                    </tr>
                </tbody>
            </table>
        </form>
    </div>
@endsection